<?php
use common\components\helpers\Fun;
use common\components\extenders\MenuManage;
\doumiaoduo\layer\LayerAsset::register($this);
?>
<div class="docs-main">
    <div>
        <?=\yii\helpers\Html::buttonInput('批量生成班级',['id'=>'batch','class'=>'btn','data-type'=>'all'])?>
    </div>
    <table id="tablesaw" class="tablesaw table yx-table1 yx-table3 table-striped with-check"  data-url="<?=Fun::url(['classmanage/generatecheck'])?>" >
    <thead>
        <tr class="yx-bgd2f6ec">
        <th></th>
        <th>学生姓名</th>
        <th>家长姓名</th>
        <th>电话号码</th>
        <th>卡号</th>
        <th>状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <?php foreach ($details as $i => $v) { ?>
        <tr>
            <td>
                <?php if($v->studentCheck == null) { ?>
                   <?=\yii\helpers\Html::checkbox('checkbox',false,['value'=>$v->id])?>
                <?php } ?>
            </td>
            <td><?=isset($v->student->name)?\yii\helpers\Html::encode($v->student->name):''?></td>
            <td><?=isset($v->student->customer)?\yii\helpers\Html::encode($v->student->customer->name):''?></td>
            <td><?=isset($v->student->customer)? \yii\helpers\Html::encode($v->student->customer->mobile):'' ?></td>
            <td><?=isset($v->student->customer)? \yii\helpers\Html::encode($v->student->customer->card_id):'' ?></td>
            <td><?php
                switch($v->status){
                    case 0:
                        echo '未开课';
                        break;
                    case 1:
                        echo '上课中';
                        break;
                    case 2:
                        echo '已结课';
                        break;
                }
                ?></td>
            <td>
                <?php if($v->studentCheck == null && $v->status == 1) { ?>
                    <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage','generatecheck',false,['rel'=>'dialog-show-iframe','class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2','data'=>['id'=>$v->id,'class_id'=>\Yii::$app->request->get('id'),'name'=>'生成签到']]);?>
                <?php } else { ?>
                    <button style="color:#ffffff;border: none;padding: 1px 12px;border-radius:2px" type="button">生成签到</button>
                <?php } ?>
                <?php if($v->status != 0  && $v->studentCheck != null){ ?>
                <?=(new MenuManage(MenuManage::TOP_MENU))->detailsMenu('classmanage','sign',true,['class' => 'btn yx-radius2 yx-d-card yx-bg94d5a2','data'=>['id'=>$v->student_id,'class_id'=>$class_id]]);?>
                <?php }else{ ?>
                    <button style="color:#ffffff;border: none;padding: 1px 12px;border-radius:2px" type="button">代打卡</button>
                <?php } ?>
            </td>
        </tr>
    <?php } ?>
</table>
   </div>
<?php
 $js = <<<JS
 // layer.config({
 //        extend: ['skin/customskin/style.css']//加载您的扩展样式
 //    });
 //    $(document).on('click','a[rel="generatecheck"],#batch',function() {
 //        //layer.msg('ddd',{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
 //         var _this = $(this);
 //         var ids = [];
 //         var type = _this.data('type');
 //         if(type == 'all'){
 //             $('input[type="checkbox"]:checked').each(function(){
 //                 ids.push($(this).val());
 //             });
 //            
 //         }else{
 //            ids.push(_this.data('id')); 
 //         }
 //         if(ids.length == 0){
 //             layer.msg('请先选择要生成签到的学生',{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
 //             return false;
 //         }
 //         _this.attr("disabled",true);
 //         _this.attr('rel','');
 //         var url = $('#tablesaw').data('url');
 //         $.ajax({
 //             url:url,
 //             type:'post',
 //             data:{ids:ids},
 //             dataType:'json',
 //             beforeSend:function(){
 //                layer.load(0, { shade: [0.5, '#393D49'] });
 //             },
 //             complete:function(){
 //              layer.close(layer.load(0, { shade: [0.5, '#393D49'] }));  
 //            },
 //            success:function(data){
 //                 if(data.status == 1){
 //                     layer.msg(data.content,{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
 //                     parent.layer.close();
 //                 }else{
 //                     layer.msg(data.content,{id:'layer-msg',skin: 'layui-msg-customskin',time: 1000});
 //                     _this.removeAttr("disabled");
 //                     _this.attr('rel','generatecheck');
 //                 }
 //       
 //            }
 //         });
 //    });
JS;
//\Yii::$app->view->registerJs($js);
?>